package com.ssf.hsdtouch.extension.Receiver;

import java.io.File;

import com.ssf.hsdtouch.extension.MainActivity;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

public class BootService extends Service {

	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}

	@Override
	public void onCreate() {
		super.onCreate();
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		new Thread(new Runnable() {

			@Override
			public void run() {
				boolean sdcard = false;
				while (!sdcard) {
					File file = new File("mnt/extsd");
					if (file.exists()) {
						if (file.canExecute() && file.canWrite()
								&& file.canRead()) {
							sdcard = true;
							Intent temp = new Intent(getApplicationContext(),
									MainActivity.class);
							temp.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
							getApplicationContext().startActivity(temp);
						}
					}
				}
				stopSelf();
			}
		}).start();
		return super.onStartCommand(intent, flags, startId);
	}
}
